{include file="public/header" /}
<style>
    .layui-form-pane .layui-form-label {width: 160px;padding: 8px 5px;}
    .layui-form-pane .layui-input-block {margin-left: 160px;left: -1px;}
    .layui-append-img {margin: 0px 10px 10px 10px;}
    .layui-append-img {height: auto !important;}
</style>
<body class="gray-bg">
<div class="layui-fluid layui-col-xs12">
    <div class="layui-card">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title">
                {volist name="Think.config.config_group_list" id="group"}
                    <a href="{:url('?id='.$key)}"><li {eq name="id" value="$key"}class="layui-this"{/eq}>{$group}配置</li></a>
                {/volist}
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show ">
                    <div class="layui-fluid">
                        <div class="layui-row layui-col-space15">
                            <!-- 遍历循环start -->
                            <div class="layui-form">
                                <div class="layui-row layui-col-space10 layui-form-item ">
                                    <div class="layui-card-body">
                                        <div class="layui-form layui-form-pane">
                                        {volist name="list" id="config"}
                                            <div class="layui-form-item layui-col-xs-offset1 layui-col-xs8">
                                                <label class="layui-form-label">{$config.title}</label>
                                                <div class="layui-input-block">
                                                    {switch name="config.type"}
                                                    {case value="0"}
                                                        <input type="text"name="config[{$config.name}]" value="{$config.value}" lay-verify="required|number" placeholder="{$config.remark}" class="layui-input ">
                                                    {/case}
                                                    {case value="1"}
                                                        <input type="text" name="config[{$config.name}]" value="{$config.value}" lay-verify="required" placeholder="{$config.remark}" class="layui-input ">
                                                    {/case}
                                                    {case value="2"}
                                                        <textarea name="config[{$config.name}]" placeholder="{$config.remark}" lay-verify="required" class="layui-textarea">{$config.value}</textarea>
                                                    {/case}
                                                    {case value="3"}
                                                        <textarea name="config[{$config.name}]" placeholder="{$config.remark}" lay-verify="required" class="layui-textarea">{$config.value}</textarea>
                                                    {/case}
                                                    {case value="4"}
                                                        <!-- 下拉 -->
<!--                                                        <select name="config[{$config.name}]" lay-verify="required" lay-search="">-->
<!--                                                            {volist name=":parse_config_attr($config['extra'])" id="vo"}-->
<!--                                                            <option value="{$key}" {eq name="config.value" value="$key"}selected{/eq}>{$vo}</option>-->
<!--                                                            {/volist}-->
<!--                                                        </select>-->

                                                        <!-- 单选 -->
                                                        {volist name=":parse_config_attr($config['extra'])" id="vo"}
                                                            <input type="radio" name="config[{$config.name}]" value="{$key}" title="{$vo}" {eq name="config.value" value="$key"}checked{/eq}>
                                                        {/volist}

                                                        <!-- 滑动 -->
<!--                                                        <input type="checkbox" value="{$key}" lay-skin="switch" lay-text="ON|OFF" {eq name="config.value" value="$key"}checked{/eq}>-->
                                                    {/case}
                                                    {case value="5"}
<!--                                                        <div class="layui-upload-list" id="lay-img-list">-->
<!--                                                            <img class="layui-append-img" style="max-width: 150px;max-height: 50px" src="{$config.value}" onerror="this.src='/static/admin/images/no_img.jpg'">-->
<!--                                                        </div>-->
                                                        <div style="display: flex;flex-direction: row;justify-content: flex-start;align-content: center;margin-left: 10px;">
                                                            <input type="hidden" name="config[{$config.name}]" id="lay-img{$key}" value="{$config.value}">
                                                            <div id="lay-upload{$key}" class="withExport">上传图片</div>
                                                            <div class="layui-upload-list" id="lay-img-list{$key}">
                                                                <img class="layui-append-img" style="max-width: 180px;max-height: 50px" src="{$config.value}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                                            </div>
                                                        </div>
                                                    {/case}
                                                    {/switch}
                                                </div>
                                            </div>
                                        {/volist}
                                        </div>
                                    </div>
                                    {if condition='!empty($list)'}
                                    <div class="layui-form-item layui-col-xs-offset1 layui-col-xs8">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                            </button>
                                        </div>
                                    </div>
                                    {/if}

                                </div>
                            </div>
                            <!-- 遍历循环end -->
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    {volist name="list" id="config"}
        // 图片上传
        if({:config('QINIU_ALLOW_STATE')} == 0){
            wk.uploadImg({size:2,num:{$key},type:'jpg,jpeg,png,ico',url:"{:url('Upload/upload')}",domain:"{:config('DOMAIN')}"});
        }else {
            wk.uploadImg({size:2,num:{$key},type:'jpg,jpeg,png,ico',url:"{:url('admin/upload/uploadLocality')}"});
        }
    {/volist}

    layui.use(['form'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            layer.prompt({
                formType: 1
                , title: '敏感操作，请验证超级管理员密码'
            }, function (value, index) {
                $.post("{:url('User/adminEdit','type=checkPassword')}",{oldpassword:value},function(res){
                    if(res.code == 100){
                        wk.error("密码错误");
                    }else{
                        layer.close(index);
                        // $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
                        $.ajax({
                            url:"{:url('save')}",
                            type:'post',
                            dataType:'json',
                            data:data.field,
                            success:function(res){
                                if (res.code == 200) {
                                    wk.success(res.msg);
                                } else {
                                    wk.error(res.msg);
                                }
                                $(".layui-btn").removeClass('layui-disabled').removeAttr('disabled');
                            }
                        })
                    }
                })
            });
        });
    });
</script>
</body>
</html>